<template>
	<basic-container>
		<avue-crud
			:option="option"
			:data="data"
			ref="crud"
			v-model="form"
			:table-loading="loading"
			:permission="permissionList"
			:page="page"
			@refresh-change="refreshChange"
			@search-change="searchChange"
			@search-reset="searchReset"
			@current-change="currentChange"
			@size-change="sizeChange"
			@selection-change="selectionChange"
			@on-load="onLoad"
		>
			<template slot-scope="{ row }" slot="menu">
				<el-button type="text" size="small"   @click.stop="showDetail(row)" >
					查看
				</el-button>
				<el-button type="text" size="small"  v-if="row.isManageGoods" @click.stop="handleEdit(row.id)" v-has="'/mall-cloud-base/goodsManage/auditOrDownSave'">
					审核上架
				</el-button>
			</template>
			<template slot-scope="{ row }" slot="goodsMainPhotoUrl">
				<img :src="row.goodsMainPhotoUrl" style="width:50px;height:50px;" />
			</template>
			<template slot="search">
				<div style="width: 25%;margin-bottom: 8px;float: left;padding: 0 20px 0 10px;box-sizing: border-box;">
					<el-form-item label="商品分类">
						<el-cascader v-model="productData" :options="chooseProductOption" size="mini" @change="handleChange"></el-cascader>
					</el-form-item>
				</div>
			</template>
		</avue-crud>
		<el-col class="btnRow" :span="8">
			<el-button @click="allPass" type="primary" size="small">审核通过</el-button>
			<el-button @click="allRefund" size="small">审核拒绝</el-button>
		</el-col>
		<el-dialog title="拒绝审核原因" :visible.sync="dialogVisibleSell" width="40%">
			<el-form ref="form" :model="form" label-width="120px" :rules="rules">
				<el-form-item label="拒绝原因" prop="auditDesc">
					<el-input type="textarea" v-model="form.auditDesc" @input="change($event)"></el-input>
					<!--v-model="editData.goodsSaleNum"-->
				</el-form-item>
			</el-form>
			<span slot="footer" class="dialog-footer">
				<el-button @click="editCancel">取 消</el-button>
				<el-button type="primary" @click="editSellSubmit">确 定</el-button>
			</span>
		</el-dialog>
		<!--    抽屉弹框-->
		<el-drawer title="我是标题" :visible.sync="dialogTableVisible" :with-header="false" size="80%">
			<avue-form ref="obj" v-model="obj" :option="optionView">
				<template slot-scope="" slot="companyName">
					<el-tag color="#fff" style="border: none;color: #333333;">{{ obj.companyName }}</el-tag>
				</template>
				<template slot-scope="" slot="storeName">
					<el-tag color="#fff" style="border: none;color: #333333;">{{ obj.storeName }}</el-tag>
				</template>
				<template slot-scope="" slot="goodsClass">
					<el-tag color="#fff" style="border: none;color: #333333;">{{ obj.goodsClassName }}</el-tag>
				</template>
				<template slot-scope="" slot="goodsClassFourName">
					<el-tag color="#fff" style="border: none;color: #333333;">{{ obj.goodsClassFourName }}</el-tag>
				</template>
				<template slot-scope="" slot="goodsName">
					<el-tag color="#fff" style="border: none;color: #333333;" class="nameShort">{{ obj.goodsName }}</el-tag>
				</template>
				<template slot-scope="" slot="brandName">
					<el-tag color="#fff" style="border: none;color: #333333;">{{ obj.brandName }}</el-tag>
				</template>
				<template slot-scope="" slot="choiceType">
					<el-tag color="#fff" style="border: none;color: #333333;" v-if="obj.choiceType == 0">实物商品</el-tag>
					<el-tag color="#fff" style="border: none;color: #333333;" v-else>虚拟商品</el-tag>
				</template>
				<template slot-scope="" slot="goodsLabel">
					<el-tag color="#fff" style="border: none;color: #333333;">{{ obj.goodsLabel }}</el-tag>
				</template>
				<template slot-scope="" slot="goodsSoRange">
					<el-select
						v-model="obj.goodsSoRangeLabel"
						size="mini"
						placeholder="请选择"
						multiple
						collapse-tags
					>
						<el-option :value="goodsSoRangeValue" style="height: auto">
							<el-tree
								:data="goodsClassIdsOptions"
								:default-expanded-keys="[]"
								node-key="id"
								accordion
								ref="goodsClassTree"
								highlight-current
								:props="propsClass"
							></el-tree>
						</el-option>
					</el-select>
				</template>
				<template slot-scope="" slot="goodsServeGuarantee">
					<span color="#fff" class="spanGoods" style="border: none;color: #333333;">{{ obj.goodsServeGuaranteeName }}</span>
				</template>
				<template slot-scope="" slot="goodsMainPhotoUrl">
					<img :src="obj.goodsMainPhotoUrl" style="height: 8rem;width: auto;" />
				</template>
				<template slot-scope="" slot="goodsPhotos">
					<div style="display: flex;overflow: scroll;">
						<div v-for="(item, i) in imgBox" :key="i" style=""><img :src="item" style="height: 8rem;width: 8rem;margin: 0 5px;" /></div>
					</div>
				</template>
				<template slot-scope="" slot="goodsVideo" v-if="obj.goodsVideo != ''">
					<video :src="obj.goodsVideo" class="avatar" controls="controls" style="height: 16rem;width: 16rem;"></video>
				</template>
				<!--<template slot-scope=""-->
				<!--slot="naturalPro">-->
				<!--<el-tag color="#fff"-->
				<!--style="border: none;color: #333333;">{{obj.naturalPro}}</el-tag>-->
				<!--</template>-->
				<template slot-scope="" slot="naturalPro">
					<avue-crud :data="dataNaturalDteail" :option="optionNaturalDteail"></avue-crud>
				</template>
				<template slot-scope="" slot="inventoryType">
					<el-tag color="#fff" style="border: none;color: #333333;" v-if="obj.inventoryType == 'all'">全局配置</el-tag>
					<el-tag color="#fff" style="border: none;color: #333333;" v-else>规格配置</el-tag>
				</template>
				<template slot-scope="scope" slot="skuDetail">
					<avue-crud :data="dataSkuDteail" :option="optionSkuDteail"></avue-crud>
				</template>

				<template slot-scope="" slot="userGoodsClassName">
					<el-tag color="#fff" style="border: none;color: #333333;">{{ obj.userGoodsClassName }}</el-tag>
				</template>
				<template slot-scope="" slot="supplierType">
					<el-tag color="#fff" style="border: none;color: #333333;" v-if="obj.supplierId == ''">自供货</el-tag>
					<el-tag color="#fff" style="border: none;color: #333333;" v-else>供货商</el-tag>
				</template>
				<template slot-scope="" slot="distributionAreaId">
					<el-tag color="#fff" style="border: none;color: #333333;" >{{obj.distributionAreaIdName}}</el-tag>
				</template>
				<template slot-scope="" slot="isSelfMention">
					<el-tag color="#fff" style="border: none;color: #333333;" v-if="!obj.isSelfMention">否</el-tag>
					<el-tag color="#fff" style="border: none;color: #333333;" v-else>是</el-tag>
				</template>
				<template slot-scope="" slot="supplierId">
					<el-tag color="#fff" style="border: none;color: #333333;">{{ obj.supplierName }}</el-tag>
				</template>
				<template slot-scope="" slot="transportName">
					<el-tag color="#fff" style="border: none;color: #333333;">{{ obj.transportName }}</el-tag>
				</template>
				<template slot-scope="" slot="goodsType">
					<div>
						<el-tag color="#fff" style="border: none;color: #333333;">长：{{ obj.goodsLength }}cm</el-tag>
						<el-tag color="#fff" style="border: none;color: #333333;">宽：{{ obj.goodsWidth }}cm</el-tag>
						<el-tag color="#fff" style="border: none;color: #333333;">高：{{ obj.goodsHeight }}cm</el-tag>
						<el-tag color="#fff" style="border: none;color: #333333;">体积：{{ obj.goodsVolume }}dm³</el-tag>
						<el-tag color="#fff" style="border: none;color: #333333;">重量：{{ obj.goodsWeight }}kg</el-tag>
					</div>
				</template>
				<!--        <template slot-scope=""-->
				<!--                  slot="goodsDetails"-->
				<!--                  :span="24">-->
				<!--          <div color="#fff"-->
				<!--               style="border: none;color: #333333;max-height: 400px;overflow: scroll;width: 800px;" v-html="obj.goodsDetails"></div>-->
				<!--        </template>-->
				<template slot-scope="" slot="goodsDetailsH5">
					<div color="#fff" style="border: none;color: #333333;max-height: 400px;overflow: scroll;width:800px;" v-html="obj.goodsDetailsH5"></div>
				</template>
				<template slot-scope="" slot="storeRecommend">
					<el-tag color="#fff" style="border: none;color: #333333;" v-if="obj.storeRecommend">是</el-tag>
					<el-tag color="#fff" style="border: none;color: #333333;" v-else>否</el-tag>
				</template>
				<template slot="goodsSort">
					<el-tag color="#fff" style="border: none;color: #333333;">{{ obj.goodsSort }}</el-tag>
				</template>
				<template slot="menuForm">
					<el-button
						@click="submitCheck(obj.goodsId, obj.goodsStatus, obj.auditDesc)"
						type="primary"
						:loading="loadBtn"
						v-has="'/mall-cloud-base/goodsManage/auditOrDownSave'"
					>
						确定
					</el-button>
					<el-button @click="cancelCheck">取消</el-button>
				</template>
			</avue-form>
		</el-drawer>
		<el-drawer title="商品详情" size="80%" :withHeader="false" :visible.sync="dialogGoodsVisible" width="80%">
			<add-goods v-if="dialogGoodsVisible" :isCheck="isCheck" :isPublish="false" :goodsId="goodsid"></add-goods>
		</el-drawer>
	</basic-container>
</template>

<script>
import { getList, getGoodsList, getClassList, getGoodsClassAll } from '@/api/base/goods/goods';
import { getGoodsClassFour,goodsSoListTree, getOrganizationMapByLevel } from '@/api/base/goods/addGoods';
import editor from '@/components/editor/richTextEditor';
import { getGoodsDetail, auditUpSave, allAuditOrDownSave,listDictsByCode,getTransAreaName } from '@/api/base/goods/goodsApprove';
import { mapGetters } from 'vuex';
import {getOrganizationTreeNodeByIds } from '@/api/base/goods/goods';
import addGoods from '@/views/base/goods/seller/addGoods';
var Dict = JSON.parse(localStorage.getItem('mall-dictionary')).content;
var CHECKDIC = [
	{
		label: '审核上架',
		value: 0
	},
	{
		label: '审核拒绝',
		value: 3
	}
];
export default {
	components: {
		editor,
		addGoods
	},
	data() {
		return {
			goodsid:'',
			isCheck:true,
			dialogGoodsVisible:false,
			goodsSoRangeValue:'',
			goodsClassIdsOptions:[],
			propsClass: {
				label: 'name',
				id: 'id',
				children: 'childrenNodes',
			},
			signOptions: [],
			props1: {
				label: 'name',
				id: 'id',
				children: 'childrenNodes',
				disabled: 'classDisplay'
			},
			dialogVisibleSell: false,
			loadBtn: false,
			drawer: false,
			imgBox: [],
			dialogTableVisible: false,
			searchForm: {},
			chooseProductOption: [],
			productData: [],
			form: {},
			query: {},
			loading: true,
			rolesTree: [],
			rolesKeys: [],
			box: false,
			goodsData: [],
			goodsForm: {},
			classData: [],
			classForm: {},
			rules: {
				auditDesc: [
					{ required: true, message: '请输入拒绝原因', trigger: 'blur' },
				],
			},
			page: {
				pageSize: 10,
				currentPage: 1,
				total: 0
			},
			cascaderProps: {
				id: 'id',
				label: 'className',
				children: 'childrenNodes'
			},
			classList: [],
			obj: {
				goodsStatus1: 0,
				auditDesc: ''
			},
			optionView: {
				card: true,
				size: 'samll',
				mock: false,
				submitBtn: false,
				emptyBtn: false,
				menuPostion: 'center',
				labelWidth: '100',
				group: [
					{
						label: '基本信息',
						prop: 'group1',
						column: [
							{
								label: '商家公司名称',
								prop: 'companyName',
								formslot: true
							},
							{
								label: '店铺名称',
								prop: 'storeName',
								formslot: true
							},
							{
								label: '商品分类',
								prop: 'goodsClass',
								formslot: true
							},
							{
								label: '税务品类名称',
								prop: 'goodsClassFourName',
								formslot: true
							},
							{
								label: '商品名称',
								prop: 'goodsName',
								formslot: true
							},
							{
								label: '商品品牌',
								prop: 'brandName',
								formslot: true
							},
							{
								label: '商品类型',
								prop: 'choiceType',
								formslot: true
							},
							{
								label: '商品标签',
								prop: 'goodsLabel',
								formslot: true
							},
							{
								label: '商品服务保障',
								disabled: true,
								prop: 'goodsServeGuarantee',
								formslot: true
								// value: 'goodsServeGuarantee',
								// type: 'tree',
								// dicUrl: '/api/dict/listDictsByCode?dictTypeCode=GOODS_SERVE_GUARANTEE',
								// dicMethod: 'post',
								// multiple: true,
								// props: {
								// 	label: 'name',
								// 	value: 'dictId'
								// },
								// searchSpan: 12
							},
							{
								label: '商品可见范围',
								disabled: true,
								formslot: true,
								prop: 'goodsSoRange',
								span: 12
							},
							{
								label: '商品图片',
								prop: 'goodsMainPhotoUrl',
								span: 24,
								formslot: true
							},
							{
								label: '商品视频',
								prop: 'goodsVideo',
								span: 24,
								formslot: true
							},
							{
								label: '图片详情',
								prop: 'goodsPhotos',
								span: 24,
								formslot: true
							}
						]
					},
					{
						label: '商品自然属性',
						prop: 'group2',
						column: [
							{
								label: '自然属性',
								prop: 'naturalPro',
								formslot: true,
								display: true
							}
						]
					},
					{
						label: '库存配置',
						prop: 'group3',
						column: [
							{
								label: '库存配置',
								prop: 'inventoryType',
								row: true,
								formslot: true
							},
							{
								prop: 'skuDetail',
								formslot: true,
								labelWidth: 5,
								row: true,
								span: 24
							}
						]
					},
					{
						label: '店铺分类',
						prop: 'group4',
						column: [
							{
								label: '本店分类',
								prop: 'userGoodsClassName',
								formslot: true
							}
						]
					},
					{
						label: '物流信息',
						prop: 'group5',
						column: [
							{
								label: '是否自提',
								prop: 'isSelfMention',
								span: 12,
								formslot: true
							},
							// {
							// 	disabled: true,
							// 	label: '配送范围',
							// 	prop: 'distributionAreaId',
							// 	span: 12,
							// 	formslot: true
							// },
							{
								label: '供货方式',
								prop: 'supplierType',
								span: 12,
								formslot: true
							},
							{
								label: '供货商',
								prop: 'supplierId',
								span: 12,
								formslot: true,
								display: true
							},
							{
								label: '运费模板',
								prop: 'transportName',
								formslot: true,
								row: true
							},
							{
								label: '商品属性',
								prop: 'goodsType',
								formslot: true,
								display: true
							}
						]
					},
					{
						label: '详情描述',
						prop: 'group6',
						column: [
							//     {
							//   label: "PC商品描述",
							//   labelWidth: '140',
							//   prop: "goodsDetails",
							//   formslot: true,
							//   row: true,
							//   span: 24,
							// },
							{
								label: 'H5商品描述',
								labelWidth: '140',
								prop: 'goodsDetailsH5',
								formslot: true,
								row: true,
								span: 24
							}
						]
					},
					{
						label: '其他信息',
						prop: 'group7',
						column: [
							{
								label: '审核发布',
								prop: 'goodsStatus',
								type: 'radio',
								row: true,
								dicData: CHECKDIC,
								// valueDefault: 0,
								rules: [
									{
										required: true
									}
								]
							},
							{
								label: '审核原因',
								prop: 'auditDesc',
								type: 'textarea',
								display: false,
								row: true,
								minRow: 1,
								maxRows: 3
							},
							{
								label: '商品推荐',
								prop: 'storeRecommend',
								formslot: true,
								row: true
							},
							{
								label: '商品权重',
								prop: 'goodsSort',
								formslot: true,
								row: true
							}
						]
					}
				]
			},
			option: {
				size: 'mini',
				excelBtn: false,
				tip: false,
				border: true,
				viewBtn: false,
				index: false,
				columnBtn: false,
				refreshBtn: false,
				searchBtn: false,
				selection: true,
				selectable:(row)=>{
					if(row.isManageGoods){
						return true
					}else{
						return false
					}
				},
				selectClearBtn: false,
				editBtn: false,
				addBtn: false,
				rowKey: 'id',
				height: 'auto',
				dialogType: 'dialog',
				align: 'center',
				menuWidth: 140,
				column: [
					{
						label: '商品图片',
						prop: 'goodsMainPhotoUrl',
						slot: true,
						rules: [
							{
								required: true,
								message: '请输入主图片',
								trigger: 'blur'
							}
						]
					},
					{
						label: '商品名称',
						prop: 'goodsName',
						search: true,
						rules: [
							{
								required: true,
								message: '请输入商品名称',
								trigger: 'blur'
							}
						]
					},
					{
						label: '商品品牌',
						prop: 'goodsBrandId',
						search: true,
						type: 'select',
						dicUrl: '/base/brand/listAll ',
						props: {
							label: 'brandName',
							value: 'id'
						},
						rules: [
							{
								required: true,
								message: '请输入商品品牌',
								trigger: 'blur'
							}
						]
					},
					{
						label: '商品分类',
						prop: 'goodsClassId',
						type: 'select',
						dicUrl: 'base/goodsClass/listDicData',
						props: {
							label: 'label',
							value: 'value'
						},
						rules: [
							{
								required: true,
								message: '请输入分类',
								trigger: 'blur'
							}
						]
					},

					{
						label: '商品状态',
						type: 'select',
						prop: 'goodsStatus',
						dicData: Dict.GOODS_STATUS
					},
					{
						label: '推荐属性',
						prop: 'storeRecommend',
						hide: true,
						rules: [
							{
								required: true,
								message: '请输入推荐属性',
								trigger: 'blur'
							}
						]
					},
					{
						label: '商品类型',
						prop: 'choiceType',
						hide: true,
						rules: [
							{
								required: true,
								message: '请输入商品类型',
								trigger: 'blur'
							}
						]
					},
					{
						label: '运费模板编号',
						prop: 'transportId',
						hide: true,
						rules: [
							{
								required: true,
								message: '请输入运费模板编号',
								trigger: 'blur'
							}
						]
					},
					{
						label: '商品评价',
						prop: 'descriptionEvaluate',
						hide: true,
						rules: [
							{
								required: true,
								message: '请输入商品评价',
								trigger: 'blur'
							}
						]
					},
					{
						label: '商城售价',
						prop: 'vipPrice',
						hide: true,
						rules: [
							{
								required: true,
								message: '请输入商城售价',
								trigger: 'blur'
							}
						]
					},
					{
						label: '商品排序',
						prop: 'goodsSort',
						hide: true,
						rules: [
							{
								required: true,
								message: '请输入商品排序',
								trigger: 'blur'
							}
						]
					},
					{
						label: '商品展示价格',
						prop: 'showPrice',
						rules: [
							{
								required: true,
								message: '请输入商品展示价格',
								trigger: 'blur'
							}
						]
					},
					// {
					// 	label: '审核拒绝原因',
					// 	prop: 'auditDesc',
					// 	// hide: true,
					// 	rules: [
					// 		{
					// 			required: true,
					// 			message: '请输入审核拒绝原因',
					// 			trigger: 'blur'
					// 		}
					// 	]
					// }
				]
			},
			data: [],
			dataSkuDteail: [],
			optionSkuDteail: {
				menu: false,
				addBtn: false,
				header: false,
				page: false,
				align: 'center',
				border: true,
				menuAlign: 'center',
				column: [
					{
						label: '规格配置',
						prop: 'skuName',
						row: true
					},
					{
						label: '商品编号',
						prop: 'skuCode',
						row: true
					},
					{
						label: '商品库存',
						prop: 'goodsStock',
						row: true
					},
					{
						label: '提醒库存数',
						labelWidth: '200',
						prop: 'remindStock',
						row: true
					},
					{
						label: '提醒库存紧张数',
						labelWidth: '200',
						prop: 'tightInventory',
						row: true
					},
					{
						label: '商城售价',
						prop: 'price',
						row: true
					},
					{
						label: '挂牌价',
						prop: 'originalPrice',
						row: true
					},
					{
						label: '结算方式',
						prop: 'commissionType',
						type: 'select',
						dicData: [
							{
								label: '结算价',
								value: 0
							},
							{
								label: '抽佣比例',
								value: 1
							}
						],
						row: true
					},
					{
						label: '结算价',
						prop: 'purchasePrice',
						row: true
					},
					{
						label: '抽佣比例',
						prop: 'commissionRate',
						row: true
					},
					{
						label: '抽佣值',
						prop: 'commissionValue',
						row: true
					}
				]
			},
			dataNaturalDteail: [],
			optionNaturalDteail: {
				menu: false,
				addBtn: false,
				header: false,
				page: false,
				align: 'center',
				menuAlign: 'center',
				column: [
					{
						label: '自然属性名称',
						prop: 'specName'
					},
					{
						label: '自然属性值',
						prop: 'specpValue'
					}
				]
			},
			delIds: [],
			fourLevel: []
		};
	},
	watch: {
		'obj.supplierId'() {
			if (this.obj.supplierId == '' || this.obj.supplierId == null) {
				//自供货
				this.optionView.group[4].column[2].display = false;
				// this.optionView.group[4].column[3].display = false
				// this.optionView.group[4].column[4].display = false
				// this.optionView.group[4].column[5].display = false
			}
		},
		// 'obj.naturalPro' () {
		//   if (this.obj.naturalPro.length == 0) {
		//     this.optionView.group[1].column[0].display = false
		//   }
		// },
		'obj.goodsStatus'() {
			if (this.obj.goodsStatus != 3) {
				this.optionView.group[6].column[1].display = false;
				//不管之前是审核拒绝还是怎样，再次审核状态的时候，需要将审核原因变为空
				this.obj.auditDesc = '';
				delete this.optionView.group[6].column[1].rules;
			} else {
				this.optionView.group[6].column[1].display = true;
				this.optionView.group[6].column[1].rules = [
					{
						required: true,
						message: '请输入审核拒绝原因',
						trigger: 'blur'
					}
				];
			}
			console.log(this.obj.auditDesc);
			console.log(this.optionView.group[6].column[1].display);
		},
		//运费模板展示不展示
		'obj.transportName'() {
			if (this.obj.transportName == '') {
				this.optionView.group[4].column[3].display = false;
			} else {
				this.optionView.group[4].column[3].display = true;
			}
		},
		//自提点
		// 'obj.isSelfMention'() {
		// 	if (this.obj.isSelfMention == 0) {
		// 		this.optionView.group[4].column[1].display = false;
		// 	} else {
		// 		this.optionView.group[4].column[1].display = true;
		// 	}
		// },
		dialogTableVisible(val) {
			if (!val) {
				this.$nextTick(() => {
					this.loadBtn = false;
				});
			}
		}
	},
	computed: {
		...mapGetters(['permission', 'userInfo']),
		permissionList() {
			return {
				delBtn: this.vaildData(this.permission['/mall-cloud-base/goods/delete'], false)
			};
		}
	},
	created() {
		console.log(this.optionView.group[2].column[1]);
		console.log(this.obj.inventoryType);
		getGoodsList().then(res => {
			if (res.data.code == 200) {
				this.goodsForm = Object.assign({}, res.data.data);
			}
		});
		getClassList().then(res => {
			if (res.data.code == 200) {
				this.classData = res.data.data;
			}
		});
		getGoodsClassAll().then(res => {
			if (res.data.code == 200) {
				this.chooseProductOption = res.data.data;
				console.log(this.chooseProductOption);
			}
		});
		if (this.fourLevel.length == 0) {
			getOrganizationMapByLevel({ level: '' }).then(res => {
				if (res.data.code == 200) {
					this.fourLevel = res.data.data;
				}
			});
		}
	},
	methods: {
		//取消审核
		cancelCheck() {
			this.dialogTableVisible = false;
		},
		//确定审核信息
		submitCheck(id, goodsStatus, auditDesc) {
			console.log('this.obj',this.obj,goodsStatus)
			if(goodsStatus !=3 && goodsStatus!=0) {
				this.$message({
					message: '请选择审核信息结果',
					type: 'error'
				});
				return;
			}
			if (goodsStatus == 3 && this.obj.auditDesc == '') {
				this.$message({
					message: '审核拒绝时必须填写拒绝原因！',
					type: 'error'
				});
				return;
			} else {
				var regEn = /[%&+]/im;
				var regCn = /[%&+]/im;
				if (regEn.test(auditDesc) || regCn.test(auditDesc)) {
					this.$message({
						type: 'error',
						message: '审核原因不能包含特殊字符'
					});
					this.loadBtn = false;
					return false;
				}
			}
			this.loadBtn = true;
			auditUpSave(id, goodsStatus, auditDesc).then(res => {
				this.loadBtn = false;
				if (res.data.code == 500) {
					this.$message({
						message: res.data.message,
						type: 'warning'
					});
					return;
				} else if (res.data.code == 200) {
					this.dialogTableVisible = false;
					this.$message({
						type: 'success',
						message: '操作成功!'
					});
					if (this.data.length == 1) {
						this.page.currentPage -= 1
					}
					this.onLoad(this.page);
				}
			});
		},
		change(){
			this.$forceUpdate()
		},
		// 选中状态变化时(结合审核通过,审核拒绝使用)
		selectionChange(list) {
			console.log('selectionList', list);
			this.delIds = [];
			list.forEach(item => {
				this.delIds.push(item.id);
			});
		},
		allPass() {
			if (this.delIds.length > 0) {
				this.$confirm('确认全部通过审核嘛?', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					this.allSubmit(0);
				});
			} else {
				this.$message({
					message: '至少选择一个商品',
					type: 'warning'
				});
			}
		},
		editCancel(){
			this.form.auditDesc=''
			this.dialogVisibleSell = false;
		},
		editSellSubmit() {
			if (!this.form.auditDesc) {
				this.$message({
					message: '审核拒绝时必须填写拒绝原因！',
					type: 'error'
				});
				return;
			} else {
				var regCn = /^[\u4e00-\u9fa5a-zA-Z0-9?!.,？！，。]+$/;
				if (!regCn.test(this.form.auditDesc)) {
					this.$message({
						type: 'error',
						message: '审核原因不能包含特殊字符'
					});
					this.loadBtn = false;
					return false;
				}
			}
			this.allSubmit(3);
		},
		allRefund() {
			if (this.delIds.length > 0) {
				this.dialogVisibleSell = true;
			} else {
				this.$message({
					message: '至少选择一个商品',
					type: 'warning'
				});
			}
		},
		//批量审核
		allSubmit(type) {
			let data = {};
			if (type == 3) {
				(data.ids = this.delIds), (data.goodsStatus = type), (data.auditDesc = this.form.auditDesc);
			} else {
				(data.ids = this.delIds), (data.goodsStatus = type);
			}

			allAuditOrDownSave(data).then(res => {
				this.loadBtn = false;
				if (res.data.code == 500) {
					this.$message({
						message: res.data.message,
						type: 'warning'
					});
					return;
				} else if (res.data.code == 200) {
					this.dialogTableVisible = false;
					this.$message({
						type: 'success',
						message: '操作成功!'
					});
					this.form.auditDesc=''
					this.delIds = [];
					this.dialogVisibleSell = false;
					if (this.data.length == 1) {
						this.page.currentPage -= 1
					}
					this.onLoad(this.page);
				}
			});
		},
		showDetail(row){
			console.log(row);
			this.goodsid = row.id;
			this.isCheck = true;
			this.dialogGoodsVisible = true;
			//  查看
		},
		handleEdit(id) {
			goodsSoListTree(id).then(res => {
				if (res.data.code == 200) {
					this.signOptions = res.data.data;
				}
			});
			let goodsServeGuarantee= []
			listDictsByCode().then(res=>{
				goodsServeGuarantee=res.data.data
			})
			getGoodsDetail(id).then(res => {
				if (res.data.code == 200) {
					this.obj = res.data.data;
					this.obj.storeWillCallName= ''
					this.obj.distributionAreaIdName = ''
					getTransAreaName(this.obj.distributionAreaId).then(address=>{
						console.log(address)
						if(address.data.data.gName){
							this.obj.distributionAreaIdName =address.data.data.gName+address.data.data.pName+address.data.data.name
						}else{
							this.obj.distributionAreaIdName =address.data.data.name
						}
					})
					let goodsLabel=res.data.data.goodsLabel.split(',')
					this.obj.goodsLabel=[]
					Dict.Goods_Label_Enum.forEach(item => {
						goodsLabel.forEach(obj=>{
							if (obj == item.value) {
								this.obj.goodsLabel.push(item.label);
							}
						})
						
					});
					
					console.log(this.obj)
					this.obj.goodsLabel=this.obj.goodsLabel.join(' | ')
					getOrganizationTreeNodeByIds(this.obj.goodsSoRange).then(res => {
						if (res.data.code == 200) {
							this.goodsClassIdsOptions = res.data.data;
						}
					});
					this.obj.goodsSoRange = this.obj.goodsSoRange.split(',');
					this.obj.goodsServeGuarantee = this.obj.goodsServeGuarantee.split(',');
					this.obj.goodsServeGuaranteeName=[]
					goodsServeGuarantee.forEach(obj => {
						this.obj.goodsServeGuarantee.forEach(item => {
							if(item==obj.dictId){
								this.obj.goodsServeGuaranteeName.push(obj.name)
							}
						});
					});
					this.obj.goodsSoRangeLabel= []
					this.obj.goodsSoRange.forEach(item => {
						if (this.fourLevel[Number(item)]) {
							this.obj.goodsSoRangeLabel.push(this.fourLevel[Number(item)]);
						}
					});
					this.obj.goodsServeGuaranteeName = this.obj.goodsServeGuaranteeName.join(' | ');
					this.imgBox = this.obj.goodsPhotos.split(',');
					this.dataSkuDteail = this.obj.goodsSkuResultList;
					this.dataNaturalDteail = res.data.data.mapNaturalList;
					this.dialogTableVisible = true;
				} else {
					this.$message({
						message: res.data.message,
						type: 'warning'
					});
					return;
				}
			});
		},
		handleClassChange() {},

		getGoodsList() {},

		searchReset() {
			this.query = {};
			this.productData = [];
			this.onLoad(this.page);
		},
		searchChange(params, done) {
			this.query = params;
			this.page.currentPage = 1;
			this.onLoad(this.page, params, done);
		},
		currentChange(currentPage) {
			this.page.currentPage = currentPage;
		},
		sizeChange(pageSize) {
			this.page.pageSize = pageSize;
		},
		refreshChange() {
			this.onLoad(this.page);
		},
		onLoad(page, params = {}, done) {
			if (this.productData != undefined) {
				params.goodsClassId = this.productData[2];
			}
			//默认查询商品状态待审核的
			if (params.goodsStatus == undefined) {
				params.goodsStatus = 2;
			}
			this.loading = true;
			this.$store.dispatch("GetREVIEWNUM");
			getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
				if (done) {
					done();
				}
				if (res.data.code == 200) {
					const data = res.data;
					this.page.total = data.count;
					this.data = data.data;
				}
				this.loading = false;
			});
		},
		handleChange() {
			// this.onLoad(this.page, params);
		}
	}
};
</script>

<style scoped>
.avue-crud__menu {
	min-height: 0px !important;
	margin-bottom: 0px !important;
}
.nameShort {
	width: 93% !important;
	overflow: hidden !important;
	margin-top: 6px !important;
	white-space: nowrap !important;
	text-overflow: ellipsis !important;
}
.avue-group__item {
	overflow: hidden;
}
.btnRow {
	position: relative;
	bottom: 51px;
	left: 10px;
}
	.spanGoods {
		display: inline-block;
		height: 32px;
		padding: 0 10px;
		line-height: 30px;
		font-size: 12px;
	}
</style>
